package top.yaofengqiao.springcloudsimple.demo.biz.infrastructure.repository;

import org.springframework.stereotype.Repository;
import top.yaofengqiao.springcloudsimple.demo.biz.domain.product.model.entity.ProductEntity;
import top.yaofengqiao.springcloudsimple.demo.biz.domain.product.repository.IProductRepository;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @author yfq
 * @date 2024/6/14 11:36
 * @description
 */
@Repository
public class ProductRepository implements IProductRepository {
    private final Map<String, ProductEntity> productEntityMap = new HashMap<String, ProductEntity>() {{
        put("1", ProductEntity.builder()
                .id("1")
                .productCode("1")
                .productType("recharge")
                .title("会员充值（虚拟商品）")
                .price(BigDecimal.valueOf(9.9))
                .build());
        put("2", ProductEntity.builder()
                .id("2")
                .productCode("2")
                .productType("recharge")
                .title("话费充值50（虚拟商品）")
                .price(BigDecimal.valueOf(48.5))
                .build());
    }};

    @Override
    public ProductEntity queryProductById(String productId) {
        return productEntityMap.get(productId);
    }

}
